#include "Host.h"
#include "NodeServer.h"


CHost::CHost()
{
	m_bCacheConnOK = false;
}

CHost::~CHost()
{
}


CHostBase* CreateHost()
{
	CHost* pHost = new CHost();
	return pHost;
}

std::string GetLogFileName()
{
	return "despatch";
}

void CHost::Init()
{
	this->m_pNode = GetNodeServer();
	this->m_pGame = new CGameServer();
	this->m_pGame->m_pHost = this;
	this->m_pGame->InitGame();

	SpiderEvent ev;
	ev.evID = NODE_EV_SET_TYPE;
	ev.evParam.iParam = SERVER_TYPE_DISPATCH;
	m_pNode->ProcEvent(NODE_EV_SET_TYPE, &ev);
	
	//vector<CONFITEM> item;
	//ev.evID = NODE_EV_SET_CACHE;
	//ev.evParam.ptr = &item;
	//m_pNode->ProcEvent(NODE_EV_SET_CACHE, &ev);


}


int CHost::OnBYTimeOut(int Timerid)
{
	return 0;
}

int CHost::ProcEvent(int ev_id, SpiderEvent* pEvent)
{
	//if (SPIDER_EV_BACK_CONNECTED == ev_id &&
	//	SERVER_TYPE_MASTER == ev_param2)
	return 0;
}

int CHost::ProcPacket(NETInputPacket* inputPkg, SocketHandler* pSocketHandler)
{
	if (NULL != m_pGame /*&& this->m_bCacheConnOK*/)
	{
		return m_pGame->ProcessPacket(pSocketHandler, inputPkg);
	}
	return 0;
}